#pragma once
#include "gtest/gtest.h"
#include "DataStructure/Input/Property/BeamSectionStandardTypes.h"
#include "../Interface/BarSectionFormulaCalculatorFactory.h"
#include "../Bar/HexaSectionFormulaCalculator.h"

using SG::Algebra::Point;
using namespace SG::DataStructure::FEM;
using SG::FEMSolver::Element::BarSectionFormulaCalculatorFactory;
using SG::FEMSolver::Element::HexaSectionFormulaCalculator;

// 将 BarSectionFormulaCalculatorFactory 生成对象测试放置在具体截面属性计算中
TEST (BarSectionFormulaCalculatorFactoryTest, HexaSectionCalculatorCreate)
{
    // Test data
    auto calculatorPtr = BarSectionFormulaCalculatorFactory::Create (BeamSectionStandardTypes::BEAMSECTYPE_HEXA);
    auto hexaCalculatorPtr = dynamic_cast<HexaSectionFormulaCalculator*> (calculatorPtr.get ());

    // Check
    ASSERT_TRUE (nullptr != hexaCalculatorPtr);
}

// Hexa 截面属性计算测试
TEST (BarSectionFormulaCalculatorTest, HexaSection)
{
    // Input data
    PBARLData section;
    section.m_id  = 2;
    section.m_mId = 3;
    section.SetGroup ("MSCBML0");
    section.SetBeamSectionStandardTypes (BeamSectionStandardTypes::BEAMSECTYPE_HEXA);
    section.m_dimension = {2.0, 6.0, 4.0};
    section.m_nsm = 10.0;

    // Test data
    HexaSectionFormulaCalculator calculator;
    PBARData propertyTest;
    Point centroidTest;
    calculator.Compute (section, _OUT propertyTest, _OUT centroidTest);

    // Target data
    PBARData propertyTarget;
    propertyTarget.m_id  = 2;
    propertyTarget.m_mId = 3;
    propertyTarget.m_A   = 16.0;
    // propertyTarget.m_yS = 0.0;
    // propertyTarget.m_zS = 0.0;
    // propertyTarget.m_yC = 0.0;
    // propertyTarget.m_zC = 0.0;
    propertyTarget.m_I1  = 16.0;
    propertyTarget.m_I2  = 26.66667;
    propertyTarget.m_I12 = 0.0;
    propertyTarget.m_J   = 36.053333;  // ToDo（正确值为：34.048）
    propertyTarget.m_K1  = 5.0 / 6.0;  // ToDo（正确值为：0.9264501）
    propertyTarget.m_K2  = 5.0 / 6.0;  // ToDo（正确值为：0.9392611）
    propertyTarget.m_NSM = 10.0;
    propertyTarget.m_FE  = 0.0;
    propertyTarget.SetStressPoints ({2.0, 0.0, -2.0, 0.0, 0.0, 3.0, 0.0, -3.0});
    Point centroidTarget;

    // Check
    ASSERT_TRUE (propertyTarget == propertyTest);
    ASSERT_TRUE (centroidTarget == centroidTest);
}